// Copyright © 2022 Cisco Systems, Inc. and its affiliates.
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package config

type Mode string

const (
	DefaultClamScanBinaryPath         = "clamscan"
	DefaultClamDaemonBinaryPath       = "clamd"
	DefaultClamDaemonClientBinaryPath = "clamdscan"
	DefaultFreshclamBinaryPath        = "freshclam"
	DefaultFreshclamConfigPath        = "/etc/clamav/freshclam.conf"
)

type Config struct {
	// UseNativeClamscan indicates that scanning should use the native (clamscan) command
	// instead of daemon (clamdscan) command.
	UseNativeClamscan             bool     `yaml:"use_native_clamscan" mapstructure:"use_native_clamscan" json:"use_native_clamscan"`
	ClamScanBinaryPath            string   `yaml:"clamscan_binary_path" mapstructure:"clamscan_binary_path" json:"clamscan_binary_path"`
	ClamScanExcludeFiles          []string `yaml:"clamscan_exclude_files" mapstructure:"clamscan_exclude_files" json:"clamscan_exclude_files"`
	ClamScanExcludeDirs           []string `yaml:"clamscan_exclude_dirs" mapstructure:"clamscan_exclude_dirs" json:"clamscan_exclude_dirs"`
	ClamDaemonClientBinaryPath    string   `yaml:"clam_daemon_client_binary_path" mapstructure:"clam_daemon_client_binary_path" json:"clam_daemon_client_binary_path"`
	ClamDaemonBinaryPath          string   `yaml:"clam_daemon_binary_path" mapstructure:"clam_daemon_binary_path" json:"clam_daemon_binary_path"`
	ClamDaemonConfigPath          string   `yaml:"clam_daemon_config_path" mapstructure:"clam_daemon_config_path" json:"clam_daemon_config_path"`
	FreshclamBinaryPath           string   `yaml:"freshclam_binary_path" mapstructure:"freshclam_binary_path" json:"freshclam_binary_path"`
	FreshclamConfigPath           string   `yaml:"freshclam_config_path" mapstructure:"freshclam_config_path" json:"freshclam_config_path"`
	AlternativeFreshclamMirrorURL string   `yaml:"alternative_freshclam_mirror_url" mapstructure:"alternative_freshclam_mirror_url" json:"alternative_freshclam_mirror_url"`
}

func (c *Config) GetFreshclamConfigPath() string {
	if c.FreshclamConfigPath != "" {
		return c.FreshclamConfigPath
	}

	return DefaultFreshclamConfigPath
}

func (c *Config) GetFreshclamBinaryPath() string {
	if c.FreshclamBinaryPath != "" {
		return c.FreshclamBinaryPath
	}

	return DefaultFreshclamBinaryPath
}

func (c *Config) GetClamDaemonClientBinaryPath() string {
	if c.ClamDaemonClientBinaryPath != "" {
		return c.ClamDaemonClientBinaryPath
	}

	return DefaultClamDaemonClientBinaryPath
}

func (c *Config) GetClamDaemonBinaryPath() string {
	if c.ClamDaemonBinaryPath != "" {
		return c.ClamDaemonBinaryPath
	}

	return DefaultClamDaemonBinaryPath
}

func (c *Config) GetClamScanBinaryPath() string {
	if c.ClamScanBinaryPath != "" {
		return c.ClamScanBinaryPath
	}

	return DefaultClamScanBinaryPath
}
